<?php
/**
 * クッキーコントロールクラス
 *
 * @auther Administrator
 * @create 2009/07/12
 */

class Lib_Cookie
{
	protected $_aryCookie;
	
	public function __construct()
	{
		$this->_aryCookie = $_COOKIE;	
	}
	
	public function setValue( $strName, $vValue, $iExpireHour = 0, $strPath = '/' )
	{
		$iExpire = time() + ( 3600 * $iExpireHour );
		if ( is_array( $vValue ) ) {
			foreach ( $vValue as $strKey=>$strValue ) {
				setcookie( $strName . '[' . $strKey . ']', $strValue, $iExpire, $strPath );
			}
		} else {
			setcookie( $strName, $vValue, $iExpire, $strPath );
		}
	}
	
	public function getValue( $strKey ) {
		if ( !isset( $this->_aryCookie[$strKey] ) ) {
			return '';
		}
		return $this->_aryCookie[$strKey];
	}
	
	public function getAll()
	{
		return $this->_aryCookie;
	}
	
	public function getCookieNames()
	{
		return array_keys( $this->_aryCookie );
	}
}
?>